package com.whm.hrmanagement.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.whm.common.annotation.Log;
import com.whm.common.core.controller.BaseController;
import com.whm.common.core.domain.AjaxResult;
import com.whm.common.enums.BusinessType;
import com.whm.hrmanagement.domain.OaPersonAsk;
import com.whm.hrmanagement.service.IOaPersonAskService;
import com.whm.common.utils.poi.ExcelUtil;
import com.whm.common.core.page.TableDataInfo;

/**
 * 招聘管理-招聘需求Controller
 * 
 * @author whm
 * @date 2024-02-04
 */
@RestController
@RequestMapping("/hrmanagement/ask")
public class OaPersonAskController extends BaseController
{
    @Autowired
    private IOaPersonAskService oaPersonAskService;

    /**
     * 查询招聘管理-招聘需求列表
     */
    @PreAuthorize("@ss.hasPermi('hrmanagement:ask:list')")
    @GetMapping("/list")
    public TableDataInfo list(OaPersonAsk oaPersonAsk)
    {
        startPage();
        List<OaPersonAsk> list = oaPersonAskService.selectOaPersonAskList(oaPersonAsk);
        return getDataTable(list);
    }

    /**
     * 导出招聘管理-招聘需求列表
     */
    @PreAuthorize("@ss.hasPermi('hrmanagement:ask:export')")
    @Log(title = "招聘管理-招聘需求", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, OaPersonAsk oaPersonAsk)
    {
        List<OaPersonAsk> list = oaPersonAskService.selectOaPersonAskList(oaPersonAsk);
        ExcelUtil<OaPersonAsk> util = new ExcelUtil<OaPersonAsk>(OaPersonAsk.class);
        util.exportExcel(response, list, "招聘管理-招聘需求数据");
    }

    /**
     * 获取招聘管理-招聘需求详细信息
     */
    @PreAuthorize("@ss.hasPermi('hrmanagement:ask:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(oaPersonAskService.selectOaPersonAskById(id));
    }

    /**
     * 新增招聘管理-招聘需求
     */
    @PreAuthorize("@ss.hasPermi('hrmanagement:ask:add')")
    @Log(title = "招聘管理-招聘需求", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody OaPersonAsk oaPersonAsk)
    {
        return toAjax(oaPersonAskService.insertOaPersonAsk(oaPersonAsk));
    }

    /**
     * 修改招聘管理-招聘需求
     */
    @PreAuthorize("@ss.hasPermi('hrmanagement:ask:edit')")
    @Log(title = "招聘管理-招聘需求", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody OaPersonAsk oaPersonAsk)
    {
        return toAjax(oaPersonAskService.updateOaPersonAsk(oaPersonAsk));
    }

    /**
     * 删除招聘管理-招聘需求
     */
    @PreAuthorize("@ss.hasPermi('hrmanagement:ask:remove')")
    @Log(title = "招聘管理-招聘需求", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(oaPersonAskService.deleteOaPersonAskByIds(ids));
    }
}
